package com.stone.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 时间帮助类 
 * @author Administrator
 *
 */
public class DateUtil {

    public static String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String DATE_FORMAT = "yyyy-MM-dd";

    public static String TIME_FORMAT = "HH:mm:ss";

    public static String DATETIMESTR_FORMAT = "yyyyMMddHHmmss";
    
    /**
     * 将时间格式转化为字符串
     * @param formatString
     * @param date
     * @return
     */
    public static String dateFormatStr(String formatString, Date date) {
    	SimpleDateFormat sdf = new SimpleDateFormat(formatString);
    	return sdf.format(date);
    }
    
    /**
     * 将时间格式转化为字符串
     * @param formatString
     * @param date
     * @return
     */
    public static Date strFormatDate(String formatString, String dateStr) {
    	Date date = null;
    	try {
        	SimpleDateFormat sdf = new SimpleDateFormat(formatString);
        	date = sdf.parse(dateStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
    }
}
